﻿' LibWowAPI
' by Ronald M. Clifford (roncli@roncli.com)
'
' This source code is released under the GNU Library General Public License (LGPL) Version 2.1.

Imports System
Imports System.Globalization
Imports System.Runtime.Serialization

Namespace roncliProductions.LibWowAPI

    ''' <summary>
    ''' A class that represents an error thrown by Blizzard's API.
    ''' </summary>
    ''' <remarks></remarks>
    Public Class BlizzardAPIException
        Inherits Exception

        ''' <summary>
        ''' The status of the request.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks>This usually will be "nok".</remarks>
        Public Property Status As String

        ''' <summary>
        ''' The reason for the error.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks>While there is a list of possible errors at http://blizzard.github.com/api-wow-docs/#id3380043 it is neither exhaustive nor 100% accurate.</remarks>
        Public Property Reason As String

        ''' <summary>
        ''' A constructor to create a new Blizzard API Exception with the status and reason.
        ''' </summary>
        ''' <param name="strStatus"></param>
        ''' <param name="strReason"></param>
        ''' <remarks></remarks>
        Public Sub New(strStatus As String, strReason As String)
            MyBase.New(String.Format(CultureInfo.InvariantCulture, "The Blizzard API threw the following error: {0} - {1}", strStatus, strReason))
            Status = strStatus
            Reason = strReason
        End Sub

        ''' <summary>
        ''' A default constructor to create a new Blizzard API Exception.
        ''' </summary>
        ''' <remarks></remarks>
        Public Sub New()
            MyBase.New()
        End Sub

        ''' <summary>
        ''' A constructor to create a new Blizzard API Exception with just a generic message.
        ''' </summary>
        ''' <param name="message"></param>
        ''' <remarks></remarks>
        Public Sub New(message As String)
            MyBase.New(message)
        End Sub

        ''' <summary>
        ''' A constructor to create a new Blizzard API Exception with a generic message and an inner exception.
        ''' </summary>
        ''' <param name="message"></param>
        ''' <param name="innerException"></param>
        ''' <remarks></remarks>
        Public Sub New(message As String, innerException As Exception)
            MyBase.New(message, innerException)
        End Sub

        Protected Sub New(info As SerializationInfo, context As StreamingContext)
            MyBase.New(info, context)
        End Sub

    End Class

End Namespace
